/*
 * @Description: 你的代码我的心
 * @Author: GGB
 * @Date: 2022-01-20 18:21:14
 * @LastEditors: GGB
 * @LastEditTime: 2022-01-22 16:17:14
 */
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
// import { h } from 'vue';
import { Tag } from 'ant-design-vue';

export const columns: BasicColumn[] = [
  {
    title: '账号',
    dataIndex: 'user_name',
    width: 100,
  },
  {
    title: '姓名',
    dataIndex: 'real_name',
    width: 100,
  },
  {
    title: '管理员',
    dataIndex: 'is_super',
    width: 100,
    slots: { title: 'customSuper', customRender: 'super' },
    customRender: ({ record }) => {
      if (!Reflect.has(record, 'pendingStatus')) {
        record.pendingStatus = false;
      }
      const tagColor = record.is_super ? 'green' : '';
      const tagText = record.is_super ? '是' : '否';
      return <Tag color={tagColor}>{tagText}</Tag>;
    },
  },
  {
    title: '角色',
    dataIndex: 'role',
    width: 100,
    slots: { title: 'customSuper', customRender: 'super' },
    customRender: ({ record }) => {
      return (
        <>
          {record.role.map((role) => {
            const tagColor = record.is_super ? 'gold' : 'green';
            return <Tag color={tagColor}>{role.role_name}</Tag>;
          })}
        </>
      );
    },
  },
  {
    title: '排序',
    dataIndex: 'sort',
    width: 100,
  },
  {
    title: '创建时间',
    dataIndex: 'create_time',
    width: 100,
  },
];
// 表格搜索框
export const searchFormSchema: FormSchema[] = [
  {
    field: 'search',
    label: '员工账号',
    component: 'Input',
    labelWidth: 70,
    colProps: { span: 5 },
  },
];
